﻿@model Marbale.BusinessObject.AppSetting
@{
    ViewBag.Title = "Formats";
    Layout = null;
}

<div style="background-color:orangered;height: 500px;">
 
 
<div id="valuesContainer">
   
      @foreach (var item in ViewBag.Formats)
      {
          int a = 1;
          String type = item.Type.ToString();
          switch (type)
          {
              case "string":
               <div>                        
                            <div class="inputwrap demo">
                             <text> &nbsp; &nbsp; &nbsp;</text>   <label> <b>@item.Caption </b>:</label>
                              
                     <input type="text" value="@item.Value" id="@item.Name" class="strings" name="myInput"/><br />

                            </div>
                    </div>

                  break;
                  case "bool":
                 
                     <div>
                          <div class="inputwrap demo">
                             <text> &nbsp; &nbsp; &nbsp;</text>  <label> <b>@item.Caption </b>:</label>
                       <input type="checkbox" value="@item.Value" class="checktrue strings" name="allcheck" id="@item.Name"/><br /> </div>

                
     </div>
                  break;
                            case "file":
                
 
    
         <div>
                          <div class="inputwrap demo">
                         <text> &nbsp; &nbsp; &nbsp;</text>     <label> <b>@item.Caption </b>:</label>
                     <input type="file" value="@item.Value" class="strings" name="fileUploader" id="@item.Name"/><br /> </div>
           
                        </div>


      

                
    
              break;
                            case "int":
                    <div>
                          <div class="inputwrap demo">
                         <text> &nbsp; &nbsp; &nbsp;</text>     <label> <b>@item.Caption </b>:</label>
                     <input type="number" value="@item.Value" class="strings" name="myInput" id="@item.Name"/><br /> </div>
                        </div>
                    
              break;

          }

      }
    
      </div>
 @*          <input type="submit"  class="button-email btn btn-primary"/>*@

      
  <button class="btn btn-primary btn-md button-pos" role="button" style="position:absolute;bottom:191px;left:500px" onclick="SaveEmail();">Save</button>   
     <a href="/Product/ClosePopUp" class="btn btn-primary button-close" style="top:675px">Close</a>
</div>
      
  
<script>
    var appSettings = [];
    var appSettings1 = [];
    $('input[name=myInput]').change(function () {
        debugger
        var d = {
            Name: this.id,
            Value: this.value,
            ScreenGroup: 'Formats'
        };
      
        appSettings.push(d);
    });
    $('input[name=fileUploader]').change(function (e) {
        debugger
        var d1 = {
            Name: this.id,
            Value: this.value,
            ScreenGroup: 'Price'
        };

        appSettings.push(d1);
       // console.log(this.files[0].mozFullPath);
    })
    $('input[name=fileUploader1]').change(function (e) {
        debugger
        var d1 = {
            Name: this.id,
            Value: this.value,
            ScreenGroup: 'Email'
        };

        appSettings.push(d1);
        // console.log(this.files[0].mozFullPath);
    })
   
    $('input[name=allcheck]').change(function () {
        debugger
        var d = {
            Name: this.id,
            Value: $(this).is(":checked"),
            ScreenGroup: 'Formats'
        };
        appSettings.push(d);
    });

   // formData.append('file', $('#PDF_WRITER_PRINTER')[0].files[0]);
    function SaveEmail() {
        debugger
        $.ajax({
            type: "POST",
            contentType: "application/json; charset=utf-8",
            url: '@Url.Action("UpdateAppSettings", "SiteSetup")',

            data: JSON.stringify({ appSettings: appSettings }),

                        dataType: "json",

                        beforeSend: function () { },

                        success: function (data) {
                            appSettings = [];
                          //  location.reload();
                            $('#displayMessage').text('data added succesfully').addClass('success');
                        }
                            });
   
    }
    $(document).ready(function () {
        $('input[name="allcheck"]').each(function (index) {
            debugger
            if ($(this).val().toLowerCase() == "true")

                ($(this).prop('checked', true));
        });
    });

</script>

<style>
    .defalut-width {
        width: 280px;
            height: 46px;
    }
    label {
    width:480px;
    clear:left;
    text-align:right;
    padding-right:10px;
}
      .button-email {
     position: absolute;
    left: 319px;
    bottom: 132px;
    }
    .button-close {
           position: absolute;
    left: 646px;
  
    top: 576px;
    }

input,button, label,.ar {
    float:left;
}
</style>
